package org.mineground.commands.player.admin;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.mineground.Main;
import org.mineground.PermissionNodes;

public class Slay implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) throws CommandException {
	Player player = (Player) sender;

	if (!player.hasPermission(PermissionNodes.PERMISSION_SLAY_COMMAND)) {
            return true;
        }
        
	if (args.length == 0) {
	    player.sendMessage(ChatColor.RED + "* Usage: '/slay <PlayerName>'");
	}

	String playerName = args[0];
	Player playerEx = Main.getInstance().getServer().getPlayer(playerName);
	playerEx.setHealth(0);
	player.sendMessage(ChatColor.GREEN + "* " + playerEx.getDisplayName() + " has been slayed.");
	playerEx.sendMessage(ChatColor.RED + "* You have been slayed.");
	return true;
    }
}
